/*
 * xbee.hpp
 *
 *  Created on: May 15, 2011
 *      Author: jmurray
 */

#ifndef XBEE_HPP_
#define XBEE_HPP_

#include <vector>
#include <string>

/*!
 * \file
 * \brief This file contains information regarding the XBee communications.
 *
 * For more details, see the functions within this file.
 */

//Define Offsets

//! This byte is the delimiter, indicating a new frame
#define DELIMITER 	0
//! The low byte of the frame length
#define LENGTH_HIGH 1
//! The high byte of the frame length
#define LENGTH_LOW 	2
//! The frame ID byte to determine which type of frame this is
#define FRAME_TYPE 	3
//! for frames that have one, this is the frame ID for UART data checking
#define FRAME_ID 	4

typedef struct {
	//! Unique ID to identify the address
	int id;

	//! ASCII string of the name of the device
	string name;

	//! A human readable description of the device
	string disc;

	//! 64 bit physical address of the device
	uint64_t pAddress;

	//! 16 bit software address assigned to the device at the time it was last seen
	uint16_t nAddress;

	//! time the address was last confirmed to be accurate
	time_t lastSeen;

}xbeeAddress;

//! This will keep a current list of the XBee frames from the network.
extern vector<xbeeAddress> GLOB_XBEE_ADDRESS;

//!This global vector will be used in outgoing frames
extern vector<char*> GLOB_FRAME_BUFFER;

//! Process the current Queue of frames that need to be transmitted, as well as receiving any in the buffer
int xbeeProcessQueue();

/*!
 *
 * @param name The name of the node to be transmitted too
 * @param data The array of data to be placed into the stream. This data will be copied, but not freed
 * @param size The number of bytes given in the data array.
 * @return \b 0 Success\n \b 1 Unknown Name
 */
int xbeeInsertDataFrame(string name, char* data, int size);

#endif /* INIT_HPP_ */
